package com.woniuxy.staff.controller;

import com.woniuxy.commons.annotation.RequirePerms;
import com.woniuxy.commons.entity.PageBean;
import com.woniuxy.commons.entity.StaffLog;
import com.woniuxy.commons.utils.ResponseResult;
import com.woniuxy.staff.service.LogService;
import com.woniuxy.staff.service.StaffLogService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author author
 * @create 2021-11-13 16:30
 */
@RestController
@RequestMapping("/staff")
public class StaffLogController {
    @Resource
    private StaffLogService staffLogService;

    @Resource
    private LogService logService;


    @GetMapping("/getAllStaffLog")
    public ResponseResult<PageBean> getAllStaffLog(int pageIndex, int pageSize) {
        List<StaffLog> allStaffLog = staffLogService.getAllStaffLog(pageIndex, pageSize);
//        List<com.woniuxy.staff.log.StaffLog> allStaffLog = logService.getall(pageIndex, pageSize);
        int i = staffLogService.selectStaffLogCount();
        PageBean pageBean = new PageBean();
        pageBean.setBeanList(allStaffLog);
        pageBean.setPageIndex(pageIndex);
        pageBean.setPageSize(pageSize);
        pageBean.setTotalRecord(i);
        ResponseResult responseResult = new ResponseResult();
        responseResult.setCode(200);
        responseResult.setMessage("查询成功");
        responseResult.setData(pageBean);
        return responseResult;

    }


    @RequirePerms("user:del")
    @DeleteMapping("/dellog/{logid}")
    public ResponseResult del(@PathVariable("logid") int logid) {
        staffLogService.delStaffLog(logid);
        ResponseResult responseResult = new ResponseResult();
        responseResult.setMessage("删除成功");
        responseResult.setCode(200);
        return responseResult;

    }








}
